<template>
  <el-card class="app-container">
    <c-u-r-d-table :option="option"/>
  </el-card>
</template>

<script>

import ColumnType from '@/framework/constant/ColumnType'
import YesNoEnum from '@/infra/constant/YesNoEnum'
import {complainFollowUpApi} from '@/feature/cmt/infra/api/complainFollowUpApi'
import CURDTable from '@/framework/components/table/CURDTable'
import ComplainFollowUpStatusEnum from "@/feature/cmt/infra/constants/ComplainFollowUpStatusEnum";
import CheckStatusEnum from "@/infra/constant/CheckStatusEnum";
import ComplainTypeEnum from "@/feature/cmt/infra/constants/ComplainTypeEnum";
import {storeApi} from "@/feature/mct/infra/api/storeApi";
import {adminApi} from "@/feature/mgr/infra/api/adminApi";
import AdminTypeEnum from "@/feature/mgr/infra/constants/AdminTypeEnum";

export default {
  components: {CURDTable},
  data() {
    return {
      option: {
        requestApi: complainFollowUpApi,
        requestApiNames: {
          list: 'listMyRegister'
        },
        showSelection: false,
        columns: [
          {
            label: '店铺',
            prop: 'storeId',
            searchable: true,
            type: ColumnType.SELECT,
            required: true,
            options: storeApi.options()
          }, {
            label: '违规编号',
            prop: 'complainNo',
            width: 'auto',
            searchable: true,
            required: false
          },
          // {
          //   label: '原图链接',
          //   searchable: true,
          //   width: 120,
          //   viewDetail: true,
          //   span: 24,
          //   type: ColumnType.TEXTAREA,
          //   prop: 'tbLink',
          //   required: true
          // },
          {
            label: '违规时间',
            width: 100,
            searchable: true,
            required: true,
            type: ColumnType.DATE,
            prop: 'complainTime'
          },
          {
            label: '投诉类型',
            width: 140,
            required: true,
            searchable: true,
            type: ColumnType.SELECT,
            options: ComplainTypeEnum,
            prop: 'complainType'
          },
          // {
          //   label: '严重程度',
          //   required: true,
          //   prop: 'severity'
          // },
          {
            label: '扣分',
            // required: true,
            width: 80,
            required: false,
            prop: 'reducePoints',
            type: ColumnType.NUMBER
          },
          // {
          //   label: '处罚状态',
          //   required: true,
          //   prop: 'punishStatus'
          // },

          {
            label: '货号/ID',
            width: 100,
            searchable: true,
            prop: 'itemNo'
          },
          {
            label: '跟进人',
            width: 100,
            searchable: true,
            type: ColumnType.SELECT,
            showFilter: ({isEdit}) => !isEdit,
            options: adminApi.listAll().then(data => {
              return data.filter(el => el.adminTypeList.includes(AdminTypeEnum.COMPLAIN_FOLLOWER.id))
            }),
            prop: 'followUpManId'
          },
          {
            label: '图片',
            prop: 'pic',
            width: 75,
            type: ColumnType.IMAGE
          },
          {
            label: '状态',
            hiddenInForm: true,
            width: 80,
            type: ColumnType.SELECT,
            searchable: true,
            options: ComplainFollowUpStatusEnum,
            prop: 'status'
          },
          {
            label: '审核状态',
            width: 90,
            type: ColumnType.RADIO,
            hiddenInForm: true,
            searchable: true,
            options: CheckStatusEnum,
            prop: 'checkStatus'
          },
          {
            label: '备注',
            width: 180,
            type: ColumnType.TEXTAREA,
            span: 24,
            prop: 'remark'
          }, {
            label: '审核备注',
            width: 180,
            hiddenInForm: true,
            prop: 'checkResult'
          }
          // {
          //   label: '创建时间',
          //   type: ColumnType.DATETIME,
          //   hiddenInForm: true,
          //   prop: 'gmtCreate'
          // },
          // {
          //   label: '修改时间',
          //   type: ColumnType.DATETIME,
          //   hiddenInForm: true,
          //   prop: 'gmtModified'
          // }
        ]
      }
    }
  },
  methods: {
    handleSubmitFollow({$service, arg}) {
      this.$confirm('确定提交吗?', '提示').then(() => {
        complainFollowUpApi.submit(arg.id).then(() => {
          this.$message.success('提交成功')
          $service.reloadTable()
        })
      })
    }
  }

}
</script>

